3.1.46 \(\int (c+d x) (a+b \tan (e+f x))^2 \, dx\) [46]

3.1.46.1 Optimal result
3.1.46.2 Mathematica [A] (verified)
3.1.46.3 Rubi [A] (verified)
3.1.46.4 Maple [A] (verified)
3.1.46.5 Fricas [A] (verification not implemented)
3.1.46.6 Sympy [F]
3.1.46.7 Maxima [B] (verification not implemented)
3.1.46.8 Giac [F]
3.1.46.9 Mupad [F(-1)]

3.1.46.1 Optimal result

Integrand size = 18, antiderivative size = 136 \[ \int (c+d x) (a+b \tan (e+f x))^2 \, dx=-b^2 c x-\frac {1}{2} b^2 d x^2+\frac {a^2 (c+d x)^2}{2 d}+\frac {i a b (c+d x)^2}{d}-\frac {2 a b (c+d x) \log \left (1+e^{2 i (e+f x)}\right )}{f}+\frac {b^2 d \log (\cos (e+f x))}{f^2}+\frac {i a b d \operatorname {PolyLog}\left (2,-e^{2 i (e+f x)}\right )}{f^2}+\frac {b^2 (c+d x) \tan (e+f x)}{f} \]

output
-b^2*c*x-1/2*b^2*d*x^2+1/2*a^2*(d*x+c)^2/d+I*a*b*(d*x+c)^2/d-2*a*b*(d*x+c) 
*ln(1+exp(2*I*(f*x+e)))/f+b^2*d*ln(cos(f*x+e))/f^2+I*a*b*d*polylog(2,-exp( 
2*I*(f*x+e)))/f^2+b^2*(d*x+c)*tan(f*x+e)/f
 
3.1.46.2 Mathematica [A] (verified)

Time = 7.41 (sec) , antiderivative size = 200, normalized size of antiderivative = 1.47 \[ \int (c+d x) (a+b \tan (e+f x))^2 \, dx=\frac {\cos (e+f x) \left (\cos (e+f x) \left (-\left ((e+f x) \left (-2 i a b d (e+f x)+a^2 (d e-2 c f-d f x)+b^2 (-d e+2 c f+d f x)\right )\right )-4 a b d (e+f x) \log \left (1+e^{2 i (e+f x)}\right )+2 b (b d+2 a d e-2 a c f) \log (\cos (e+f x))\right )+2 i a b d \cos (e+f x) \operatorname {PolyLog}\left (2,-e^{2 i (e+f x)}\right )+2 b^2 f (c+d x) \sin (e+f x)\right ) (a+b \tan (e+f x))^2}{2 f^2 (a \cos (e+f x)+b \sin (e+f x))^2} \]

input
Integrate[(c + d*x)*(a + b*Tan[e + f*x])^2,x]
 
output
(Cos[e + f*x]*(Cos[e + f*x]*(-((e + f*x)*((-2*I)*a*b*d*(e + f*x) + a^2*(d* 
e - 2*c*f - d*f*x) + b^2*(-(d*e) + 2*c*f + d*f*x))) - 4*a*b*d*(e + f*x)*Lo 
g[1 + E^((2*I)*(e + f*x))] + 2*b*(b*d + 2*a*d*e - 2*a*c*f)*Log[Cos[e + f*x 
]]) + (2*I)*a*b*d*Cos[e + f*x]*PolyLog[2, -E^((2*I)*(e + f*x))] + 2*b^2*f* 
(c + d*x)*Sin[e + f*x])*(a + b*Tan[e + f*x])^2)/(2*f^2*(a*Cos[e + f*x] + b 
*Sin[e + f*x])^2)
 
3.1.46.3 Rubi [A] (verified)

Time = 0.39 (sec) , antiderivative size = 135, normalized size of antiderivative = 0.99, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.167, Rules used = {3042, 4205, 2009}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int (c+d x) (a+b \tan (e+f x))^2 \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (c+d x) (a+b \tan (e+f x))^2dx\)

\(\Big \downarrow \) 4205

\(\displaystyle \int \left (a^2 (c+d x)+2 a b (c+d x) \tan (e+f x)+b^2 (c+d x) \tan ^2(e+f x)\right )dx\)

\(\Big \downarrow \) 2009

\(\displaystyle \frac {a^2 (c+d x)^2}{2 d}-\frac {2 a b (c+d x) \log \left (1+e^{2 i (e+f x)}\right )}{f}+\frac {i a b (c+d x)^2}{d}+\frac {i a b d \operatorname {PolyLog}\left (2,-e^{2 i (e+f x)}\right )}{f^2}+\frac {b^2 (c+d x) \tan (e+f x)}{f}-\frac {b^2 (c+d x)^2}{2 d}+\frac {b^2 d \log (\cos (e+f x))}{f^2}\)

input
Int[(c + d*x)*(a + b*Tan[e + f*x])^2,x]
 
output
(a^2*(c + d*x)^2)/(2*d) + (I*a*b*(c + d*x)^2)/d - (b^2*(c + d*x)^2)/(2*d) 
- (2*a*b*(c + d*x)*Log[1 + E^((2*I)*(e + f*x))])/f + (b^2*d*Log[Cos[e + f* 
x]])/f^2 + (I*a*b*d*PolyLog[2, -E^((2*I)*(e + f*x))])/f^2 + (b^2*(c + d*x) 
*Tan[e + f*x])/f
 

3.1.46.3.1 Defintions of rubi rules used

rule 2009
Int[u_, x_Symbol] :> Simp[IntSum[u, x], x] /; SumQ[u]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4205
Int[((c_.) + (d_.)*(x_))^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.) 
, x_Symbol] :> Int[ExpandIntegrand[(c + d*x)^m, (a + b*Tan[e + f*x])^n, x], 
 x] /; FreeQ[{a, b, c, d, e, f, m}, x] && IGtQ[m, 0] && IGtQ[n, 0]
 
3.1.46.4 Maple [A] (verified)

Time = 1.31 (sec) , antiderivative size = 238, normalized size of antiderivative = 1.75

method result size
risch \(-\frac {b^{2} d \,x^{2}}{2}+\frac {4 i b a d e x}{f}+\frac {a^{2} d \,x^{2}}{2}-b^{2} c x -2 i a b c x +a^{2} c x +\frac {2 i b a d \,e^{2}}{f^{2}}+\frac {b^{2} d \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}{f^{2}}-\frac {2 b^{2} d \ln \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}-\frac {2 b a c \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}{f}+\frac {4 b a c \ln \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{f}-\frac {4 b e a d \ln \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}+\frac {2 i b^{2} \left (d x +c \right )}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}+\frac {i a b d \,\operatorname {Li}_{2}\left (-{\mathrm e}^{2 i \left (f x +e \right )}\right )}{f^{2}}+i a b d \,x^{2}-\frac {2 b a d \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) x}{f}\) \(238\)

input
int((d*x+c)*(a+b*tan(f*x+e))^2,x,method=_RETURNVERBOSE)
 
output
-1/2*b^2*d*x^2+4*I/f*b*a*d*e*x+1/2*a^2*d*x^2-b^2*c*x-2*I*a*b*c*x+a^2*c*x+2 
*I/f^2*b*a*d*e^2+1/f^2*b^2*d*ln(exp(2*I*(f*x+e))+1)-2/f^2*b^2*d*ln(exp(I*( 
f*x+e)))-2/f*b*a*c*ln(exp(2*I*(f*x+e))+1)+4/f*b*a*c*ln(exp(I*(f*x+e)))-4/f 
^2*b*e*a*d*ln(exp(I*(f*x+e)))+2*I*b^2*(d*x+c)/f/(exp(2*I*(f*x+e))+1)+I*a*b 
*d*polylog(2,-exp(2*I*(f*x+e)))/f^2+I*a*b*d*x^2-2/f*b*a*d*ln(exp(2*I*(f*x+ 
e))+1)*x
 
3.1.46.5 Fricas [A] (verification not implemented)

Time = 0.26 (sec) , antiderivative size = 219, normalized size of antiderivative = 1.61 \[ \int (c+d x) (a+b \tan (e+f x))^2 \, dx=\frac {{\left (a^{2} - b^{2}\right )} d f^{2} x^{2} + 2 \, {\left (a^{2} - b^{2}\right )} c f^{2} x - i \, a b d {\rm Li}_2\left (\frac {2 \, {\left (i \, \tan \left (f x + e\right ) - 1\right )}}{\tan \left (f x + e\right )^{2} + 1} + 1\right ) + i \, a b d {\rm Li}_2\left (\frac {2 \, {\left (-i \, \tan \left (f x + e\right ) - 1\right )}}{\tan \left (f x + e\right )^{2} + 1} + 1\right ) - {\left (2 \, a b d f x + 2 \, a b c f - b^{2} d\right )} \log \left (-\frac {2 \, {\left (i \, \tan \left (f x + e\right ) - 1\right )}}{\tan \left (f x + e\right )^{2} + 1}\right ) - {\left (2 \, a b d f x + 2 \, a b c f - b^{2} d\right )} \log \left (-\frac {2 \, {\left (-i \, \tan \left (f x + e\right ) - 1\right )}}{\tan \left (f x + e\right )^{2} + 1}\right ) + 2 \, {\left (b^{2} d f x + b^{2} c f\right )} \tan \left (f x + e\right )}{2 \, f^{2}} \]

input
integrate((d*x+c)*(a+b*tan(f*x+e))^2,x, algorithm="fricas")
 
output
1/2*((a^2 - b^2)*d*f^2*x^2 + 2*(a^2 - b^2)*c*f^2*x - I*a*b*d*dilog(2*(I*ta 
n(f*x + e) - 1)/(tan(f*x + e)^2 + 1) + 1) + I*a*b*d*dilog(2*(-I*tan(f*x + 
e) - 1)/(tan(f*x + e)^2 + 1) + 1) - (2*a*b*d*f*x + 2*a*b*c*f - b^2*d)*log( 
-2*(I*tan(f*x + e) - 1)/(tan(f*x + e)^2 + 1)) - (2*a*b*d*f*x + 2*a*b*c*f - 
 b^2*d)*log(-2*(-I*tan(f*x + e) - 1)/(tan(f*x + e)^2 + 1)) + 2*(b^2*d*f*x 
+ b^2*c*f)*tan(f*x + e))/f^2
 
3.1.46.6 Sympy [F]

\[ \int (c+d x) (a+b \tan (e+f x))^2 \, dx=\int \left (a + b \tan {\left (e + f x \right )}\right )^{2} \left (c + d x\right )\, dx \]

input
integrate((d*x+c)*(a+b*tan(f*x+e))**2,x)
 
output
Integral((a + b*tan(e + f*x))**2*(c + d*x), x)
 
3.1.46.7 Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 527 vs. \(2 (123) = 246\).

Time = 0.41 (sec) , antiderivative size = 527, normalized size of antiderivative = 3.88 \[ \int (c+d x) (a+b \tan (e+f x))^2 \, dx=\frac {2 \, {\left (f x + e\right )} a^{2} c + \frac {{\left (f x + e\right )}^{2} a^{2} d}{f} - \frac {2 \, {\left (f x + e\right )} a^{2} d e}{f} + 4 \, a b c \log \left (\sec \left (f x + e\right )\right ) - \frac {4 \, a b d e \log \left (\sec \left (f x + e\right )\right )}{f} + \frac {2 \, {\left ({\left (2 \, a b + i \, b^{2}\right )} {\left (f x + e\right )}^{2} d - 4 \, b^{2} d e + 4 \, b^{2} c f + 2 \, {\left (-i \, b^{2} d e + i \, b^{2} c f\right )} {\left (f x + e\right )} - 2 \, {\left (2 \, {\left (f x + e\right )} a b d - b^{2} d + {\left (2 \, {\left (f x + e\right )} a b d - b^{2} d\right )} \cos \left (2 \, f x + 2 \, e\right ) - {\left (-2 i \, {\left (f x + e\right )} a b d + i \, b^{2} d\right )} \sin \left (2 \, f x + 2 \, e\right )\right )} \arctan \left (\sin \left (2 \, f x + 2 \, e\right ), \cos \left (2 \, f x + 2 \, e\right ) + 1\right ) + {\left ({\left (2 \, a b + i \, b^{2}\right )} {\left (f x + e\right )}^{2} d + 2 \, {\left (-i \, b^{2} d e + i \, b^{2} c f - 2 \, b^{2} d\right )} {\left (f x + e\right )}\right )} \cos \left (2 \, f x + 2 \, e\right ) + 2 \, {\left (a b d \cos \left (2 \, f x + 2 \, e\right ) + i \, a b d \sin \left (2 \, f x + 2 \, e\right ) + a b d\right )} {\rm Li}_2\left (-e^{\left (2 i \, f x + 2 i \, e\right )}\right ) - {\left (-2 i \, {\left (f x + e\right )} a b d + i \, b^{2} d + {\left (-2 i \, {\left (f x + e\right )} a b d + i \, b^{2} d\right )} \cos \left (2 \, f x + 2 \, e\right ) + {\left (2 \, {\left (f x + e\right )} a b d - b^{2} d\right )} \sin \left (2 \, f x + 2 \, e\right )\right )} \log \left (\cos \left (2 \, f x + 2 \, e\right )^{2} + \sin \left (2 \, f x + 2 \, e\right )^{2} + 2 \, \cos \left (2 \, f x + 2 \, e\right ) + 1\right ) - {\left ({\left (-2 i \, a b + b^{2}\right )} {\left (f x + e\right )}^{2} d - 2 \, {\left (b^{2} d e - b^{2} c f - 2 i \, b^{2} d\right )} {\left (f x + e\right )}\right )} \sin \left (2 \, f x + 2 \, e\right )\right )}}{-2 i \, f \cos \left (2 \, f x + 2 \, e\right ) + 2 \, f \sin \left (2 \, f x + 2 \, e\right ) - 2 i \, f}}{2 \, f} \]

input
integrate((d*x+c)*(a+b*tan(f*x+e))^2,x, algorithm="maxima")
 
output
1/2*(2*(f*x + e)*a^2*c + (f*x + e)^2*a^2*d/f - 2*(f*x + e)*a^2*d*e/f + 4*a 
*b*c*log(sec(f*x + e)) - 4*a*b*d*e*log(sec(f*x + e))/f + 2*((2*a*b + I*b^2 
)*(f*x + e)^2*d - 4*b^2*d*e + 4*b^2*c*f + 2*(-I*b^2*d*e + I*b^2*c*f)*(f*x 
+ e) - 2*(2*(f*x + e)*a*b*d - b^2*d + (2*(f*x + e)*a*b*d - b^2*d)*cos(2*f* 
x + 2*e) - (-2*I*(f*x + e)*a*b*d + I*b^2*d)*sin(2*f*x + 2*e))*arctan2(sin( 
2*f*x + 2*e), cos(2*f*x + 2*e) + 1) + ((2*a*b + I*b^2)*(f*x + e)^2*d + 2*( 
-I*b^2*d*e + I*b^2*c*f - 2*b^2*d)*(f*x + e))*cos(2*f*x + 2*e) + 2*(a*b*d*c 
os(2*f*x + 2*e) + I*a*b*d*sin(2*f*x + 2*e) + a*b*d)*dilog(-e^(2*I*f*x + 2* 
I*e)) - (-2*I*(f*x + e)*a*b*d + I*b^2*d + (-2*I*(f*x + e)*a*b*d + I*b^2*d) 
*cos(2*f*x + 2*e) + (2*(f*x + e)*a*b*d - b^2*d)*sin(2*f*x + 2*e))*log(cos( 
2*f*x + 2*e)^2 + sin(2*f*x + 2*e)^2 + 2*cos(2*f*x + 2*e) + 1) - ((-2*I*a*b 
 + b^2)*(f*x + e)^2*d - 2*(b^2*d*e - b^2*c*f - 2*I*b^2*d)*(f*x + e))*sin(2 
*f*x + 2*e))/(-2*I*f*cos(2*f*x + 2*e) + 2*f*sin(2*f*x + 2*e) - 2*I*f))/f
 
3.1.46.8 Giac [F]

\[ \int (c+d x) (a+b \tan (e+f x))^2 \, dx=\int { {\left (d x + c\right )} {\left (b \tan \left (f x + e\right ) + a\right )}^{2} \,d x } \]

input
integrate((d*x+c)*(a+b*tan(f*x+e))^2,x, algorithm="giac")
 
output
integrate((d*x + c)*(b*tan(f*x + e) + a)^2, x)
 
3.1.46.9 Mupad [F(-1)]

Timed out. \[ \int (c+d x) (a+b \tan (e+f x))^2 \, dx=\int {\left (a+b\,\mathrm {tan}\left (e+f\,x\right )\right )}^2\,\left (c+d\,x\right ) \,d x \]

input
int((a + b*tan(e + f*x))^2*(c + d*x),x)
 
output
int((a + b*tan(e + f*x))^2*(c + d*x), x)